package com.bigfire.dtm.core.web.facade.impl;

import com.bigfire.dtm.api.dto.resp.CapabilityRespDTO;
import com.bigfire.dtm.api.web.facade.CapabilityFacade;
import com.bigfire.dtm.domain.ability.aggregate.ProgrammerCompetenceModel;
import com.bigfire.dtm.shared.common.Pagination;
import com.bigfire.dtm.shared.common.ResponseWrapper;
import com.bigfire.dtm.shared.constant.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
 * @author Damon S.
 * @version v1.0.1
 * @date 2020年05月05日 14:47
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "胜任力模型实现")
public class CapabilityFacadeImpl implements CapabilityFacade {

    @Override
    @ApiOperation(value = "获取能力评估结果", notes = "获取个人能力评估模型结果")
    public ResponseWrapper<Pagination<CapabilityRespDTO>> findByUserId(HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Cache-Control","no-cache");

        ProgrammerCompetenceModel programmerCompetenceModel1 = new ProgrammerCompetenceModel(6, 3, 10, 3, 2, 2, 1, 20000, 7, 1, 0.8, 5, 1, 1);

        double outputV1 = programmerCompetenceModel1.getCompetenceOutputValue();
        double feeV1 = programmerCompetenceModel1.getCompetenceFeeRateValue();
        double wishV1 = programmerCompetenceModel1.getCompetenceWishValue();
        double capabilityV1 = programmerCompetenceModel1.getCompetenceCapabilityValue();
        double personalV1 = programmerCompetenceModel1.getCompetenceGrowValue();

        //程序员2的胜任力
        //Programmer programmer2 = new Programmer(8,3.5,10,2,1,4,2,25000,7,1.25,1.2,2,0,2);
        ProgrammerCompetenceModel programmerCompetenceModel2 = new ProgrammerCompetenceModel(8, 3.5, 10, 2, 1, 4, 2, 25000, 7, 1.25, 1.2, 2, 0, 2);

        double outputV2 = programmerCompetenceModel2.getCompetenceOutputValue();
        double feeV2 = programmerCompetenceModel2.getCompetenceFeeRateValue();
        double wishV2 = programmerCompetenceModel2.getCompetenceWishValue();
        double capabilityV2 = programmerCompetenceModel2.getCompetenceCapabilityValue();
        double personalV2 = programmerCompetenceModel2.getCompetenceGrowValue();

        CapabilityRespDTO c1 = CapabilityRespDTO.builder().userId(10000L).displayName("程序员1")
                .output(outputV1).cost(feeV1).will(wishV1).ability(capabilityV1).growUp(personalV1)
                .build();

        CapabilityRespDTO c2 = CapabilityRespDTO.builder().userId(20000L).displayName("程序员2")
                .output(outputV2).cost(feeV2).will(wishV2).ability(capabilityV2).growUp(personalV2)
                .build();

        return new ResponseWrapper<>(
                new Pagination<>(Constants.LONG_ONE, Constants.LONG_TEN, 2L, Arrays.asList(c1, c2))
        );
    }

    @Override
    @ApiOperation(value = "获取能力评估结果", notes = "根据用户Id获取个人能力评估模型结果")
    public ResponseWrapper<CapabilityRespDTO> findByUserId(
            @PathVariable("userId")Long userId, HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Cache-Control","no-cache");

        ProgrammerCompetenceModel programmerCompetenceModel1 = new ProgrammerCompetenceModel(6, 3, 10, 3, 2, 2, 1, 20000, 7, 1, 0.8, 5, 1, 1);

        double outputV1 = programmerCompetenceModel1.getCompetenceOutputValue();
        double feeV1 = programmerCompetenceModel1.getCompetenceFeeRateValue();
        double wishV1 = programmerCompetenceModel1.getCompetenceWishValue();
        double capabilityV1 = programmerCompetenceModel1.getCompetenceCapabilityValue();
        double personalV1 = programmerCompetenceModel1.getCompetenceGrowValue();

        //程序员2的胜任力
        //Programmer programmer2 = new Programmer(8,3.5,10,2,1,4,2,25000,7,1.25,1.2,2,0,2);
        ProgrammerCompetenceModel programmerCompetenceModel2 = new ProgrammerCompetenceModel(8, 3.5, 10, 2, 1, 4, 2, 25000, 7, 1.25, 1.2, 2, 0, 2);

        double outputV2 = programmerCompetenceModel2.getCompetenceOutputValue();
        double feeV2 = programmerCompetenceModel2.getCompetenceFeeRateValue();
        double wishV2 = programmerCompetenceModel2.getCompetenceWishValue();
        double capabilityV2 = programmerCompetenceModel2.getCompetenceCapabilityValue();
        double personalV2 = programmerCompetenceModel2.getCompetenceGrowValue();

        CapabilityRespDTO c1 = CapabilityRespDTO.builder().userId(10000L).displayName("程序员1")
                .output(outputV1).cost(feeV1).will(wishV1).ability(capabilityV1).growUp(personalV1)
                .build();

        return new ResponseWrapper<>(c1);
    }
}
